{
  "cells": [
    {
      "cell_type": "markdown",
      "source": [
        "# ElasticNet Regression"
      ],
      "metadata": {}
    },
    {
      "cell_type": "markdown",
      "source": [
        "Elastic net is a regularized regression method that use L1 and L2 penalties of the lasso and ridge methods. "
      ],
      "metadata": {}
    },
    {
      "cell_type": "code",
      "source": [
        "import numpy as np\n",
        "import matplotlib.pyplot as plt\n",
        "import pandas as pd\n",
        "\n",
        "import warnings\n",
        "warnings.filterwarnings(\"ignore\")\n",
        "\n",
        "# fix_yahoo_finance is used to fetch data \n",
        "import fix_yahoo_finance as yf\n",
        "yf.pdr_override()"
      ],
      "outputs": [],
      "execution_count": 1,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# input\n",
        "symbol = 'AMD'\n",
        "start = '2014-01-01'\n",
        "end = '2018-08-27'\n",
        "\n",
        "# Read data \n",
        "dataset = yf.download(symbol,start,end)\n",
        "\n",
        "# View Columns\n",
        "dataset.head()"
      ],
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "[*********************100%***********************]  1 of 1 downloaded\n"
          ]
        },
        {
          "output_type": "execute_result",
          "execution_count": 2,
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>Open</th>\n",
              "      <th>High</th>\n",
              "      <th>Low</th>\n",
              "      <th>Close</th>\n",
              "      <th>Adj Close</th>\n",
              "      <th>Volume</th>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>Date</th>\n",
              "      <th></th>\n",
              "      <th></th>\n",
              "      <th></th>\n",
              "      <th></th>\n",
              "      <th></th>\n",
              "      <th></th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>2014-01-02</th>\n",
              "      <td>3.85</td>\n",
              "      <td>3.98</td>\n",
              "      <td>3.84</td>\n",
              "      <td>3.95</td>\n",
              "      <td>3.95</td>\n",
              "      <td>20548400</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2014-01-03</th>\n",
              "      <td>3.98</td>\n",
              "      <td>4.00</td>\n",
              "      <td>3.88</td>\n",
              "      <td>4.00</td>\n",
              "      <td>4.00</td>\n",
              "      <td>22887200</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2014-01-06</th>\n",
              "      <td>4.01</td>\n",
              "      <td>4.18</td>\n",
              "      <td>3.99</td>\n",
              "      <td>4.13</td>\n",
              "      <td>4.13</td>\n",
              "      <td>42398300</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2014-01-07</th>\n",
              "      <td>4.19</td>\n",
              "      <td>4.25</td>\n",
              "      <td>4.11</td>\n",
              "      <td>4.18</td>\n",
              "      <td>4.18</td>\n",
              "      <td>42932100</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2014-01-08</th>\n",
              "      <td>4.23</td>\n",
              "      <td>4.26</td>\n",
              "      <td>4.14</td>\n",
              "      <td>4.18</td>\n",
              "      <td>4.18</td>\n",
              "      <td>30678700</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>"
            ],
            "text/plain": [
              "            Open  High   Low  Close  Adj Close    Volume\n",
              "Date                                                    \n",
              "2014-01-02  3.85  3.98  3.84   3.95       3.95  20548400\n",
              "2014-01-03  3.98  4.00  3.88   4.00       4.00  22887200\n",
              "2014-01-06  4.01  4.18  3.99   4.13       4.13  42398300\n",
              "2014-01-07  4.19  4.25  4.11   4.18       4.18  42932100\n",
              "2014-01-08  4.23  4.26  4.14   4.18       4.18  30678700"
            ]
          },
          "metadata": {}
        }
      ],
      "execution_count": 2,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "code",
      "source": [
        "X = dataset[['Open', 'High', 'Low', 'Volume']]\n",
        "Y = dataset['Adj Close']"
      ],
      "outputs": [],
      "execution_count": 3,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "code",
      "source": [
        "from sklearn.linear_model import ElasticNet\n",
        "from sklearn.datasets import make_regression"
      ],
      "outputs": [],
      "execution_count": 4,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "code",
      "source": [
        "X, Y = make_regression(n_features=2, random_state=0)"
      ],
      "outputs": [],
      "execution_count": 5,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "code",
      "source": [
        "regr = ElasticNet(random_state=0)\n",
        "regr.fit(X, Y)"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 6,
          "data": {
            "text/plain": [
              "ElasticNet(alpha=1.0, copy_X=True, fit_intercept=True, l1_ratio=0.5,\n",
              "      max_iter=1000, normalize=False, positive=False, precompute=False,\n",
              "      random_state=0, selection='cyclic', tol=0.0001, warm_start=False)"
            ]
          },
          "metadata": {}
        }
      ],
      "execution_count": 6,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "code",
      "source": [
        "print(regr.coef_)"
      ],
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "[18.83816048 64.55968825]\n"
          ]
        }
      ],
      "execution_count": 7,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "code",
      "source": [
        "print(regr.intercept_)"
      ],
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "1.4512607561654027\n"
          ]
        }
      ],
      "execution_count": 8,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "code",
      "source": [
        "print(regr.predict([[0, 0]]))"
      ],
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "[1.45126076]\n"
          ]
        }
      ],
      "execution_count": 9,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "code",
      "source": [
        "regr.score(X, Y, sample_weight=None)"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 10,
          "data": {
            "text/plain": [
              "0.8904453086976037"
            ]
          },
          "metadata": {}
        }
      ],
      "execution_count": 10,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "Stock ElasticNet Regression"
      ],
      "metadata": {}
    },
    {
      "cell_type": "code",
      "source": [
        "from sklearn.cross_validation import train_test_split\n",
        "X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size = 0.2, random_state = 0)"
      ],
      "outputs": [
        {
          "output_type": "stream",
          "name": "stderr",
          "text": [
            "C:\\Users\\Tin Hang\\Anaconda3\\envs\\py35\\lib\\site-packages\\sklearn\\cross_validation.py:41: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. Also note that the interface of the new CV iterators are different from that of this module. This module will be removed in 0.20.\n",
            "  \"This module will be removed in 0.20.\", DeprecationWarning)\n"
          ]
        }
      ],
      "execution_count": 11,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "code",
      "source": [
        "enet = ElasticNet(random_state=0)\n",
        "enet = regr.fit(X_train, Y_train)"
      ],
      "outputs": [],
      "execution_count": 12,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "code",
      "source": [
        "Y_pred = enet.predict(X_test)"
      ],
      "outputs": [],
      "execution_count": 13,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "code",
      "source": [
        "print(X_train.shape)\n",
        "print(Y_train.shape)\n",
        "print(X_test.shape)\n",
        "print(Y_test.shape)"
      ],
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "(80, 2)\n",
            "(80,)\n",
            "(20, 2)\n",
            "(20,)\n"
          ]
        }
      ],
      "execution_count": 14,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "code",
      "source": [
        "enet.score(X_train, Y_train)"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 16,
          "data": {
            "text/plain": [
              "0.8688235608979287"
            ]
          },
          "metadata": {}
        }
      ],
      "execution_count": 16,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# score measure the proportion of correctly classified instances\n",
        "enet.score(X_test, Y_test)"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 18,
          "data": {
            "text/plain": [
              "0.859843606021029"
            ]
          },
          "metadata": {}
        }
      ],
      "execution_count": 18,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# coefficient is a constant by which a variable is multiplied\n",
        "enet.coef_"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 19,
          "data": {
            "text/plain": [
              "array([19.34408276, 61.11112372])"
            ]
          },
          "metadata": {}
        }
      ],
      "execution_count": 19,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "code",
      "source": [
        "enet.intercept_"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 20,
          "data": {
            "text/plain": [
              "-0.8197636133494073"
            ]
          },
          "metadata": {}
        }
      ],
      "execution_count": 20,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "code",
      "source": [
        "from sklearn.metrics import r2_score\n",
        "\n",
        "y_pred_enet = enet.fit(X_train, Y_train).predict(X_test)\n",
        "r2_score_enet = r2_score(Y_test, Y_pred)\n",
        "\n",
        "print(enet)\n",
        "print(\"r^2 on test data : %f\" % r2_score_enet)"
      ],
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "ElasticNet(alpha=1.0, copy_X=True, fit_intercept=True, l1_ratio=0.5,\n",
            "      max_iter=1000, normalize=False, positive=False, precompute=False,\n",
            "      random_state=0, selection='cyclic', tol=0.0001, warm_start=False)\n",
            "r^2 on test data : 0.859844\n"
          ]
        }
      ],
      "execution_count": 26,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "code",
      "source": [
        "plt.plot(enet.coef_, color='blue', linewidth=2,\n",
        "         label='Elastic net coefficients')\n",
        "plt.legend(loc='best')\n",
        "plt.title(\"Elastic Net R^2: %f\"\n",
        "          % (r2_score_enet))\n",
        "plt.show()"
      ],
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "image/png": [
              "iVBORw0KGgoAAAANSUhEUgAAAXQAAAEICAYAAABPgw/pAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAIABJREFUeJzt3XmYVNW19/HvklkGGQQkooJxYJJusCGgV9BInEgcoterr8aBwVnjRESNmtyYBEciAUSCCIrKJCoOiIIiCMisohAnlIggtCiTMnX3ev/YB26D3XTRdNWprv59nqee7l116tQ6XbBq1T777G3ujoiIlH/7xR2AiIiUDSV0EZEMoYQuIpIhlNBFRDKEErqISIZQQhcRyRBK6BWImV1mZu8kYb8XmdnrZb3f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fz+Ap/k3nttddo3749WVlZnHzyyUD4BnHdddcBkJuby7nnnkuHDh3o0KEDM2fOBOBPf/oTPXr04MQTT+Twww9nwIABO/++n3/+OdnZ2fTp04dVq1bRpUsXsrOzadOmDTNmzCibN1ikDHz8MXTtCtddB5s2wbnnwtKlcNllkJLTO4lkfcJSVr2i36sCdQkrgPeN7usL3FfSfkqq0EOPU9nfSrLffvt5VlbWztvo0aPdfdfKd+3ate7unpeX5127dvX333/f165d60cddZQXRB+933//vbv/tELf0d66das3b97c586d6+7u69ev9+3bt+8Sy1tvveV16tTxr776yvPz871Tp04+Y8YM37Ztm3fu3NnXrFnj7u6jR4/2yy+//Cdx7q5jx44+YcIEd3ffvHmz//DDDz5+/Hjv1q2b5+Xl+TfffOOHHHKIr1y50idPnuy9e/f2goICz8/P9+7du/vbb7/t7u6HHXaY5+bm7oyxe/fuO19jx+uvWbPGmzZturOS3/E3e+KJJ/zaa691d/cLL7zQZ8yY4e7uy5cv9xYtWri7+z333OOdO3f2LVu2eG5urtevX9+3bdv2kwr9wQcf9HvvvXfne7Fhw4afHLMqdEm1bdvc//5392rVQs5p3Nh9/Piy2z8JVugljkM3szpAF6I1DT2sybjNzM4CTow2GwlMo9ACv+VJjRo1eO+99/a4zdixYxk6dCh5eXmsWrWKJUuW0KpVK6pXr06vXr3o3r07v/71r/e4j48//pgmTZrQoUMHAOrUqVPkdh07dqRp06YAZGdn8+WXX1K3bl0+/PBDfvWrXwGQn59PkyZNinz+Dhs3buTrr7/mnHPOAcJFNwDvvPMOF154IZUqVaJx48Z07dqVefPmMX36dF5//XXatWsHwKZNm/j000/p0qXLHl9nh3fffZcuXbrsHANev379n2wzZcqUXfrbN2zYsPNbSvfu3alWrRrVqlWjUaNGrF69+ifP79ChAz169GD79u2cffbZZGdnJxSbSLIsWgQ9e4afEKrxhx6CIv75J10iFxYdTlhQ9gkzywIWAL8HGntYlR13X2VmjfY1mHRd3vSLL77gwQcfZN68edSrV4/LLruMLVu2ULlyZebOncvU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R+PmV0M5ABdkxpR8u3xmM1sP6A/cFmqAkqyRN7jyoRulxMJ38BmmFkbd1+X5NiSJZFjvhAY4e4PmVln4KnomAuSH15skpq/0q1CXwEcUqjdlJ9+Ddu5jZlVJnxV29NXnHSXyDFjZt2AO4Ez3X1rimJLlpKOuTbQBphmZl8S+honluMTo4n+u37R3be7+xfAx4QEX14lcsw9gbEA7j4bqE6YxCqTJfT/vbTSLaHPA440s+ZmVpVw0nPibttMBC6Nfj8PeNOjsw3lVInHHHU/PEZI5uW9bxVKOGZ3X+/uB7p7M3dvRjhvcKa7z48n3H2WyL/rFwgnvzGzAwldMMtSGmXZSuSY/wOcDGBmLQkJPTelUabeROCSaLRLJ2C9u68qs73HfVa4mLPAnxDOkN8Z3fe/hP/QEN70ccBnwFzg8LhjTsExTwFWA+9Ft4lxx5zsY95t22mU41EuCb7HBjwMLAEWAxfEHXMKjrkVMJMwAuY94JS4Yy6DY34WWAVsJ1TjPYGrgKsKvc+Dor/J4rL+d61L/0VEMkS6dbmIiEgpKaGLiGQIJXQRkQyhhC4ikiGU0EVEMoQSuohIhlBCFxHJEP8fJrwbxTldCqQAAAAASUVORK5CYII=\n"
            ],
            "text/plain": [
              "<Figure size 432x288 with 1 Axes>"
            ]
          },
          "metadata": {}
        }
      ],
      "execution_count": 30,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    }
  ],
  "metadata": {
    "kernel_info": {
      "name": "python3"
    },
    "language_info": {
      "name": "python",
      "mimetype": "text/x-python",
      "version": "3.5.5",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py"
    },
    "kernelspec": {
      "name": "python3",
      "language": "python",
      "display_name": "Python 3"
    },
    "nteract": {
      "version": "0.12.2"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 4
}